package com.example;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class test {
    void test01() throws InterruptedException {
        //这个是打开谷歌浏览器驱动
        WebDriverManager.chromedriver().setup();
        //增加浏览器配置，创建驱动对象，强制允许方法所有连接.
        ChromeOptions chromeOptions=new ChromeOptions();
        chromeOptions.addArguments("--remote-allow-origins=*");
        WebDriver webDriver=new ChromeDriver(chromeOptions);
        //设置窗口大小
        //最大化
//        webDriver.manage().window().maximize();
//        //最小化
//        webDriver.manage().window().minimize();
//        //全屏
//        webDriver.manage().window().fullscreen();
        //手动设置大小
        //webDriver.manage().window().setSize(new Dimension(1024,768));
        webDriver.get("https://www.baidu.com");
        Thread.sleep(2000);
        webDriver.findElement(By.cssSelector("#kw")).sendKeys("烟雨江湖");
        Thread.sleep(2000);

        webDriver.findElement(By.cssSelector("#su")).click();
        System.out.println(webDriver.getTitle());
        System.out.println(webDriver.getCurrentUrl());


        System.out.println(webDriver.getWindowHandle());
        webDriver.quit();
    }

    public static void main(String[] args) throws InterruptedException {
        test test=new test();
        test.test01();
    }

}
